var vue = new Vue({
    el: "#app",
    data: {
        toasts: [],  //吐司
        dest: {},  //目的地
        catalogs: [], //概况中攻略分类
        strategies: [],  //点击量前3
        page: {}  //游记分页
    },
    methods: {
        commPage: function (page) {
            var param = getParams();
            var p = $("#travelForm").serialize() + "&destId=" + param.id + "&currentPage=" + page;
            //游记分页
            ajaxGet("/travels/query?" + p, {}, function (data) {
                vue.page = data.data;
                buildPage(vue.page.number, vue.page.totalPages, vue.doPage)
            })
        },
        doPage: function (page) {
            this.commPage(page);
        },
        conditionChange: function () {
            this.commPage(1);
        }
    },
    mounted: function () {
        var param = getParams();

        //  前后端分离的目的地吐司查询
        ajaxGet('/destinations/toasts', {destId: param.id}, function (data) {
            var list = data.data;
            // 设置目的地
            vue.dest = list.pop();
            vue.toasts = list;
        });

        //  概况分类
        ajaxGet('/destinations/catalogs', {destId: param.id}, function (data) {
            var list = data.data;
            vue.catalogs = list;
        });

        //点击量前3的攻略文章
        //strategies 后续还有游记点击量前3, 用于区分
        ajaxGet("/destinations/strategies/viewnumTop3", {destId: param.id}, function (data) {
            vue.strategies = data.data;
        });

        //travels 游记点击量前3
        ajaxGet("/travels/query", {destId: param.id}, function (data) {
            vue.page = data.data;
            console.log(data.data);
        })


        /*
                //var _this = this;
                //吐司
                ajaxGet("/destinations/toasts",{destId:param.id}, function (data) {
                    var list = data.data;  //中国  广东  广州
                    vue.dest = list.pop();  //数组弹出最后一个
                    vue.toasts = list;
                })



                //目的下所有攻略分类
                ajaxGet("/destinations/catalogs", {destId:param.id}, function (data) {
                    vue.catalogs = data.data;
                })



                //点击量前3的攻略文章
                //strategies 后续还有游记点击量前3, 用于区分
                //travels 游记点击量前3
                ajaxGet("/destinations/strategies/viewnumTop3", {destId:param.id}, function (data) {
                    vue.strategies = data.data;
                })

                //游记分页
                ajaxGet("/travels/query", {destId:param.id}, function (data) {
                    vue.page = data.data;
                    buildPage(vue.page.number, vue.page.totalPages, vue.doPage)
                })*/
    }
});

